package com.yunyao.dao.service.system.impl;

import com.yunyao.common.web.util.StringUtils;
import com.yunyao.dao.model.SysMenu;
import com.yunyao.dao.mapper.SysMenuMapper;
import com.yunyao.dao.service.system.ISysMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 菜单表 服务实现类
 * </p>
 *
 * @author xingjishuai
 * @since 2024-07-02
 */
@Service(value = "yunyaoSysMenuService")
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {
    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Override
    public List<SysMenu> getMenuListByRoleIds(String roleIds) {
        /**
         * roleIds 转换为 List
         */
        if (StringUtils.isNotEmpty(roleIds)) {
            List<String> roleIdList = Arrays.stream(roleIds.split(",")).toList();
            return sysMenuMapper.getMenuListByRoleIds(roleIdList);
        }else {
            return sysMenuMapper.getMenuListByRoleIds(null);
        }
    }
}
